<?php
/**
 * When the application is in maintenence mode, this filter redirects all requests to the page,
 * which contains is a message saying that the system is in inaccessible now. 
 * @author jan
 */
class MaintenenceFilter {
    private static $CONTROLLER = 'page';
    private static $METHOD = 'index';

    public static function process() {
    	if (Kohana::config('yosemin.maintenenceMode') && ! (Router::$controller == self::$CONTROLLER && Router::$method == self::$METHOD)) {
    		url::redirect(self::$CONTROLLER . '/' . self::$METHOD);
    	}
    }
}

if (Kohana::config('yosemin.maintenenceMode')) {
	Event::add('system.post_routing', array('MaintenenceFilter', 'process'));
}
